package com.halixun.d2app.adapter;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.halixun.d2app.R;
import com.halixun.d2app.adapter.holder.NavigationViewHolder;
import com.halixun.d2app.base.BaseViewHolder;
import com.halixun.d2app.bean.SettingInfo;

import java.util.List;

/**
 * @ProjectName: D2App
 * @Package: com.halixun.d2app.adapter
 * @ClassName: NavigationAdapter
 * @Description: java类作用描述
 * @Author: hdx
 * @CreateDate: 2019/12/3 17:40
 * @UpdateUser: hdx
 * @UpdateDate: 2019/12/3 17:40
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class NavigationAdapter extends RecyclerView.Adapter<BaseViewHolder<SettingInfo>> {

    private List<SettingInfo> infos;

    private SettingNavigationListener listener;

    public NavigationAdapter(List<SettingInfo> infos){
        this.infos = infos;
    }

    @NonNull
    @Override
    public BaseViewHolder<SettingInfo> onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new NavigationViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.setting_navigation_item_layout,parent,false),listener);
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder<SettingInfo> holder, int position) {
        holder.setLayoutInfo(infos.get(position));
    }

    @Override
    public int getItemCount() {
        return infos.size();
    }

    public void setOnSettingNavigationListener(SettingNavigationListener listener){
        this.listener = listener;
    }

    public interface SettingNavigationListener{
        void onSettingNavigationClickListener(int position);
    }
}
